package admin

import (
	_ "embed"
	. "go-caipu/pkg/services/sqlstore/migrator"
)

//go:embed sql/sys_dict_type.sql
var dictTypeSQLByte []byte

func AddDictTypeMigrations(mg *Migrator) {
	userV1 := Table{
		Name: "sys_dict_type",
		Columns: []*Column{
			{Name: "dict_id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
			{Name: "dict_name", Type: DB_NVarchar, Length: 64, Nullable: true},
			{Name: "dict_type", Type: DB_NVarchar, Length: 128, Nullable: false},
			{Name: "status", Type: DB_Int, Length: 4, Nullable: true},
			{Name: "is_System", Type: DB_Int, Length: 4, Nullable: true},
			{Name: "remark", Type: DB_NVarchar, Length: 255, Nullable: true},

			{Name: "create_by", Type: DB_BigInt, Nullable: false},
			{Name: "update_by", Type: DB_BigInt, Nullable: true},
			{Name: "created_at", Type: DB_DateTime, Nullable: false},
			{Name: "updated_at", Type: DB_DateTime, Nullable: true},
		},
		Indices: []*Index{
			{Cols: []string{"DictName"}, Type: UniqueIndex},
		},
	}
	//create table
	mg.AddMigration("create table sys_dict_type", NewAddTableMigration(userV1))

	//sqlPath := filepath.Join(util.GetProgramPath(), "/pkg/services/sqlstore/migrations/admin/sql/sys_dict_type.sql")
	//content, err := os.ReadFile(sqlPath)
	//if err != nil {
	//	panic(fmt.Sprintf("read sql file:sys_dict_type.sql path:%s err:%s", sqlPath, err.Error()))
	//}
	mg.AddMigration("insert into sys_dict_type", NewRawSQLMigration(string(dictTypeSQLByte)))
}
